cmake_minimum_required(VERSION 3.10)

project(watchdog)

message("CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
# 平台检测，或者指定编译工具链等
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
    set(IS_LINUX 1)
else()
    #默认为windows的mingw64平台
    set(IS_WINDOWS 1)
endif()

file(GLOB_RECURSE SRC_LIST watchdog.cpp
    ${PROJECT_SOURCE_DIR}/../export_def.h
    ${PROJECT_SOURCE_DIR}/../common/common.cpp
    ${PROJECT_SOURCE_DIR}/../common/common.h
    ${PROJECT_SOURCE_DIR}/../common/fileutil/fileutil.cpp
    ${PROJECT_SOURCE_DIR}/../common/fileutil/fileutil.h
    ${PROJECT_SOURCE_DIR}/../common/xorcrypto/xorcrypto.c
    ${PROJECT_SOURCE_DIR}/../common/xorcrypto/xorcrypto.h
    ${PROJECT_SOURCE_DIR}/../common/convertutf/ConvertUTF.c
    ${PROJECT_SOURCE_DIR}/../common/convertutf/ConvertUTF.h
    ${PROJECT_SOURCE_DIR}/../common/simpleini/SimpleIni.h)

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/../communication)
include_directories(${PROJECT_SOURCE_DIR}/../common)
include_directories(${PROJECT_SOURCE_DIR}/../common/fileutil)
include_directories(${PROJECT_SOURCE_DIR}/../common/convertutf)
include_directories(${PROJECT_SOURCE_DIR}/../common/simpleini)
include_directories(${PROJECT_SOURCE_DIR}/../../thirdparty/inc)

link_directories(${PROJECT_SOURCE_DIR}/../../thirdparty/lib)
link_directories(${PROJECT_SOURCE_DIR}/../../bin)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../bin)
add_executable(${PROJECT_NAME} ${SRC_LIST})

if (0)

    #暂时列从可支持编译平台
    if(${BUILD_PLATFORM} MATCHES "linux-arm")
        #linux-arm平台
    else()
        #if(CMAKE_SYSTEM_NAME MATCHES "Windows")  #windows平台
        if(${BUILD_PLATFORM} MATCHES "windows")
            #windows平台
            target_link_libraries(${PROJECT_NAME} m pthread)
        else()
            #linux-x86平台
            target_link_libraries(${PROJECT_NAME} dl rt m pthread)
        endif()
    endif()

else()

    if(IS_WINDOWS)
        #windows平台
        target_link_libraries(${PROJECT_NAME} m pthread)
    else()
        #linux-x86平台
        target_link_libraries(${PROJECT_NAME} dl rt m pthread)
    endif()

endif()

